<?php

/**
 * MVM_MALL 网上商店系统 商品展示位置
 * ============================================================================
 * 版权所有 (C) 2007-2010 www.mvmmall.com，并保留所有权利。
 * 网站地址: http://www.mvmmall.com
 * ----------------------------------------------------------------------------
 * 这是一个免费开源的软件；这意味着您可以在不用于商业目的的前提下对程序代码
 * 进行修改、使用和再发布。
 * ============================================================================
 * $Author:  www.mvmmall.com  $
 * $Date: 2008-04-12 $
 * $Id: goods.php  www.mvmmall.com$
 * ---------------------------------------------
*/

require_once './include/common.inc.php';
require_once MVMMALL_ROOT.'./include/pager.class.php';
$query = false;
switch ($action)
{
    case 'new':
        {
            $query    =  "goods_status = '1' and upv = '1' and up_date<='$m_now_time'";
            $cat_name = $lang['goods_new'];//最新商品
            $tpl_name = 'goods';
             break;
        } 
    case 'best':
        {
            $query    =  " WHERE goods_status = '2'   AND upv = '1' AND up_date<='$m_now_time'";
            $cat_name = $lang['goods_best'] ;//推荐商品
            $list_num = 20;
            $tpl_name = 'goods';
             break;
        } 

    case 'hot':
        {
            $query    =  " WHERE goods_status = '3'  AND upv = '1' AND up_date<='$m_now_time'";
            $cat_name = $lang['goods_hot'];//热门商品
            $tpl_name = 'goods';
            break;
        } 
    case 'sales':
        {
            $query    =  " WHERE goods_class = '1' AND start_date<='$m_now_time' AND end_date >= '$m_now_time' AND upv = '1' AND up_date<='$m_now_time'";
            $cat_name = $lang['goods_sales'];//促销商品
            $tpl_name = 'sales';//摸板文件名
             break;
        } 
    default:
        {
            show_msg('pass_worng');
            exit();
        } 
}
$total_count = $db->counter("{$tablepre}goods_table",$query);
$page        = $page ? (int)$page : 1;
$list_num    = $mm_limit_list;//后台可控制显示数量
$rowset      = new Pager($total_count,$list_num,$page);
$from_record = $rowset->_offset();
$goods       = GetGoods($action,$list_num,$from_record,0);

if ($rewrite == 1) {
    $baseurl = str_replace('1.html','',GetBaseUrl('goods',$action));
    $exc='.html';
} else{
    $baseurl = GetBaseUrl('goods',$action).'&page=';
}
$page_list   = $rowset->link($baseurl, $exc);
$navigation  = make_navigation($cat_name,$baseurl.$page.$exc);//导航
require_once MVMMALL_ROOT . 'header.php';
require_once template($tpl_name);
footer();
